-
Notifications
You must be signed in to change notification settings - Fork 8k
low cost power shield solution #95056
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
hakehuang
commented
Aug 27, 2025
- Create adc_power_shield sample for any board with adc can be used for power measurement.
- Add general_adc_platform power shiled, which can be used for power measurement with the sample application.
- the power data is stored in the power_shield folder for further analysis
log for mimxrt595_evk board
|
59e3ca2
to
8f0f3f4
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please take a look at #94585, and only keep 1 platform per vendor.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks @JarmouniA PR #94585 looks good, I will update according after your PR merged
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is no need to wait for it to be merged, just apply the same filtering and only keep overlay/conf of 1 platform per vendor in the new sample.
|
||
config SEQUENCE_32BITS_REGISTERS | ||
bool "ADC data sequences are on 32bits" | ||
default n |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
default n |
pinctrl-0 = <&adc0_default>; | ||
pinctrl-names = "default"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
move above child node
samples/drivers/adc/adc_power_shield/boards/s32z2xxdc2_s32z270_rtu0.overlay
Show resolved
Hide resolved
c19dcd6
to
78d25a9
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, this is a really great addition
# Additional development tools | ||
ipython>=8.0.0 | ||
jupyter>=1.0.0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are these actually used here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
right, it is added by my local setting, will remove it
# Set UTF-8 encoding for stdout/stderr | ||
os.environ['PYTHONIOENCODING'] = 'utf-8' | ||
|
||
# For Python 3.7+, you can also reconfigure stdout/stderr | ||
if hasattr(sys.stdout, 'reconfigure'): | ||
sys.stdout.reconfigure(encoding='utf-8') | ||
sys.stderr.reconfigure(encoding='utf-8') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move this under def main
or __name__ == "__main__"
so that the module is cleanly importable?
b5f1df0
to
af6248f
Compare
I define a dft (device for test) which can also extend to multi-application build |
:name: Analog-to-Digital Converter (ADC) power shield sample | ||
:relevant-api: adc_interface | ||
|
||
Read analog inputs from ADC channels, using a sequence. | ||
|
||
Overview | ||
******** | ||
|
||
This sample is to enable general power shield for platfroms that have ADC support. | ||
|
||
|
||
Building and Running | ||
******************** | ||
|
||
Make sure that the ADC is enabled (``status = "okay";``) and has each channel as a | ||
child node, with your desired settings like gain, reference, or acquisition time and | ||
oversampling setting (if used). It is also needed to provide an alias ``adc0`` for the | ||
desired adc. See :zephyr_file:`boards/nrf52840dk_nrf52840.overlay | ||
<samples/drivers/adc/adc_dt/boards/nrf52840dk_nrf52840.overlay>` for an example of | ||
such setup. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All of this is very stale and copied from the original sample (related: do you really need to duplicate the 100s of overlays too??). I have to admit I don't really understand what this is trying to accomplish and the fact that the README hasn't been updated is not really helping.
Just a thought but, if you are calling this a "shield" then maybe you want to create an actual shield (or snippet?), and not a sample?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kartben, the sample application is modified from adc_sequence sample. The idea here is to create a general power shield, which means any adc featured zephyr platform can be used as a power shield. so we can take any of those 100s boards and flashed with this sample, you can use them as general_power_shield fixture for measuring power, see the https://github.com/zephyrproject-rtos/zephyr/blob/af6248f8b7509f505982b8fe5d6e9a6efd8bc0f5/scripts/pylib/power-twister-harness/README.rst this is a full picture for the usage.
the sample readme is just describe how the sample runs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment thread still applies IMO. I am sorry if I am missing something but simply copying an existing code sample (and its dozens of overlays!) and then calling this a "shield" while shields are something completely different in Zephyr is really incredibly confusing.
Please don't ask for re-review when comments havne't been addressed - the README being an exact copy-paste of the original sample is also pretty problematic. Thanks!
@nashif please take a look. Thanks |
enable power shield testing on mimxrt595_evk ``` scripts/twister --device-testing --device-serial /dev/ttyACM0 -T samples/boards/nxp/mimxrt595_evk/system_off -X pm_probe:/dev/ttyACM1,115200 ``` an power_shield folder will be created in the build path whith measured voltage/current/power Signed-off-by: Hake Huang <[email protected]>
add power_shield sample for general_adc_platform power shiled, to record power/voltage/current Signed-off-by: Hake Huang <[email protected]>
1. general power shield work with the adc_power_shield sample 2. config samples to config probe 3. add readme Signed-off-by: Hake Huang <[email protected]>
enable power measure on power_mgmt_soc for mimxrt1060_evk@C Signed-off-by: Hake Huang <[email protected]>
abd034c
to
815f2b6
Compare
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Has it been considered to just use the ADC shell and a "blank" application? Setting up and performing a reading can be done directly using the shell, no custom parsing of console input/output should be needed.
the main purpose of this harness is for CI. As we want to a unified test approach, if in a blank application, you will have to customize it by you own, in this case, you are not using CI. for example, you will not know which ADC channel is connect to which power rails, you have parse them according how you connect your ADC probes, and then you have to write your own script to do so. This is what I try to avoid. Please take a look at https://github.com/zephyrproject-rtos/zephyr/pull/95056/files#diff-9e48191a8fd4eac8e1fb6d4f1c73c35c3cdc65720c3eb6264964eb104e612534 |
We already have a twister harness for the shell, can it not be reused? and regarding the specific ADC channel, that can be added in an overlay when building surely, like this PR is already doing? We can also add a custom shell command to use specifically if needed, no need to implement command line parsing in the sample |
@bjarki-andreasen if you look at my PR, I add a 'dft' which reuse the whole pytest serial handler see
the channels_p and channel_n to the power rail "VDD_CORE" / "VDD_IO" is by your board setting definition, this could be different pre your test harness setting, and this has to be customized, here is use a yaml to control it.
so nowhat where to add, we either add shell command or use a dedicated power shield sample application, we have to parse the shell/command output to get the board settings on its probe capacities, see below.
and we need map the probe capacities to the target measure power rails as I mentioned above. My understanding is that you propose to use a series of shell command to replace the power measure sample which will be running on power shield. this will add adc shell linked with power calculations I am not sure this will accepted by ADC shell owner? As in this PR, we have an independent sample to host everything, move those to shell command needs approval, can you help to confirm on my understanding and if accepted by ADC shell group I can move the implement to shell. |
No changes to the adc shell is needed. We would just create a set of custom shell commands as part of the power shield sample. The issue is not with having a sample at all, we need that, but with how the serial communication is implemented. We can freely create sample specific shell commands, so why not use that? |
ok, I see, I will update this PR to add a sample specific shell command. but I have some concerns on the code size, I enable the stm32f030dlk as the low cost shield, which code size is very critical. Let me try and feedback. |
For this, enable SHELL_MINIMAL, the entire shell should "only" take up 6-8K ROM, if that is too much we may have to go with a custom solution |